package com.ksvip.next.components.core.bean;

import java.io.Serializable;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * @Desc: 命令处理器，统一返回类
 * @Time: 2023/12/12 13:57
 */
@Setter
@Getter
@ToString
public class Result<T> implements Serializable {

    private static final long serialVersionUID = -5953959062120928535L;
    /**
     * 返回码
     */
    protected String          respCode;
    /** (title = "返回描述") */
    protected String          respMsg;
    /** (title = "结果信息") */
    protected T               result;

    public Result() {
        this.respCode = "000000";
        this.respMsg = "成功";
    }

    public static <T> Result<T> fail(String respCode, String respMsg) {
        Result<T> r = new Result<>();
        r.respCode = respCode;
        r.respMsg = respMsg;
        return r;
    }

    public static <T> Result<T> data(T data) {
        Result<T> r = new Result<>();
        r.result = data;
        return r;
    }

    public static <T> Result<T> success() {
        Result<T> r = new Result<>();
        return r;
    }

}
